# Maintainer: Kevin Daudt <kdaudt@alpinelinux.org>
pkgname=geodns
pkgver=3.3.0
pkgrel=5
pkgdesc="DNS server with per-client targeted responses"
url="https://github.com/abh/geodns"
arch="all"
license="Apache-2.0"
makedepends="go"
subpackages="$pkgname-openrc $pkgname-logs"
source="$pkgname-$pkgver.tar.gz::https://github.com/abh/geodns/archive/v$pkgver.tar.gz
	$pkgname.initd
	$pkgname.confd
	"

export GOFLAGS="$GOFLAGS -modcacherw"
export GOCACHE="${GOCACHE:-"$srcdir/go-cache"}"
export GOTMPDIR="${GOTMPDIR:-"$srcdir"}"
export GOMODCACHE="${GOMODCACHE:-"$srcdir/go"}"

build() {
	go build -v

	cd geodns-logs
	go build -v
}

check() {
	go test
}

package() {
	install -Dm0755 "$builddir"/geodns "$pkgdir/usr/bin/geodns"

	install -Dm0644 "$builddir"/dns/geodns.conf.sample "$pkgdir"/etc/geodns/geodns.conf

	install -Dm0644 "$srcdir/$pkgname.confd" "$pkgdir/etc/conf.d/$pkgname"
	install -Dm0755 "$srcdir/$pkgname.initd" "$pkgdir/etc/init.d/$pkgname"
}

logs() {
	install -Dm0755 "$builddir"/geodns-logs/geodns-logs "$subpkgdir"/usr/bin/geodns-logs
}

sha512sums="
4240d4827c403ab81cb3bdbb36b5f408144bf5ff20669b46dcd9ce452ca0d29549983a6de2897b2611bd8a7c26540423600affc40dc27ab669d5e730fd2d6ae3  geodns-3.3.0.tar.gz
dc315782eb77627e2cd23a78ebef2f85a0a37a9129f6e16c817d7b9540c8b02987d35fc46882d7752c09caca825c5a77d2d3a27ae19ccccf2bba2e04bc74940c  geodns.initd
ce2c7f51151313fa35f132f05cb59458eabb0a74208a79d585d579ce88d0ab168eab389fd59e931b4b19da7fcbca202bf495af345156e47dccb187b746b3ee15  geodns.confd
"
